/*
 *  $Id: PhoenixRitual.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Fire.Abilities {
    public class PhoenixRitual: AbilityCard<Creature> {
        public PhoenixRitual(): base("001_f_a_phoenix_ritual") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Fire;
            Target = new CreatureTarget(GetTargetPhrase(), true, false, IsNotPhoenix);
            AddManaCost(ElementType.Fire, 1);
            AddCondition(new DelegateCondition(GetConditionPhrase(), HasPhoenix));
        }

        protected override void DoAction(TargetArgs<Creature> args) {
            Creature victim = args.Target;
            Creature phoenix = args.Player.GetCreature(IsPhoenix);
            if (phoenix.Disabled) phoenix.State = CreatureState.Untapped;
            phoenix.HealBy(NewDamage(args, DamageType.Health, phoenix.HealthToMax));
            victim.InstantDeath();
        }

        private static bool IsNotPhoenix(TargetRequest request, Creature creature) {
            return !IsPhoenix(creature);
        }
        private static bool HasPhoenix(AbstractObject caster, Card card) {
            return caster.Owner.GetCreature(IsPhoenix) != null;
        }
        private static bool IsPhoenix(Creature creature) {
            return creature.Card is Creatures.Phoenix;
        }
    }
}
